package com.jt.admin.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jt.admin.domain.entity.CottonEntity;
import com.jt.admin.service.CottonService;
import com.jt.admin.common.utils.PageUtils;
import com.jt.admin.common.utils.R;



/**
 * 标准棉信息 
 *
 * @author jiangt
 * @email 
 * @date 2021-04-05 17:55:58
 */
@RestController
@RequestMapping("cotton")
public class CottonController {
    @Autowired
    private CottonService cottonService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cottonService.queryPage(params);

        return R.success().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		CottonEntity cotton = cottonService.getById(id);

        return R.success().put("cotton", cotton);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody CottonEntity cotton){
		cottonService.save(cotton);

        return R.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CottonEntity cotton){
		cottonService.updateById(cotton);

        return R.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		cottonService.removeByIds(Arrays.asList(ids));

        return R.success();
    }

}
